package org.nobject.common.swing.g;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionListener;

import javax.swing.JButton;

/**
 * GButton
 *
 * @author bianrongjun
 * @version 1.0
 */
public class GButton extends JButton implements IG{

	/**
	 * 构造函数 
	 */
	public GButton() {
		super();
		this.core=new GComponent();
	}

	/**
	 * 构造函数 
	 * @param container
	 * @param name
	 * @param text
	 */
	public GButton(Container container,String name,String text){
		this();
		if(name!=null) this.setName(name);
		if(text!=null) this.setText(text);
		if(container!=null) container.add(this);
	}

	/**
	 * 构造函数 
	 * @param container
	 * @param name
	 * @param text
	 * @param actionListener
	 */
	public GButton(Container container,String name,String text,ActionListener actionListener){
		this(container, name,text);
		this.addActionListener(actionListener);
	}
	
	/**
	 * 构造函数 
	 * @param container
	 * @param name
	 * @param text
	 * @param actionCommand
	 */
	public GButton(Container container,String name,String text,String actionCommand){
		this(container, name,text);
		if(actionCommand!=null) this.setActionCommand(actionCommand);
	}
	
	/**
	 * 构造函数 
	 * @param container
	 * @param name
	 * @param text
	 * @param actionCommand
	 */
	public GButton(Container container,String text,ActionListener actionListener){
		this(container, null,text);
		this.addActionListener(actionListener);
	}
	
	public GButton(Container container,String text,ActionListener actionListener,Dimension size){
		this(container, null,text);
		this.addActionListener(actionListener);
		this.setSize(size);
		this.setPreferredSize(size);
	}
	
	/**
	 * 构造函数 
	 * @param text
	 * @param actionCommand
	 */
	public GButton(String text,String actionCommand){
		this(null,null,text);
		if(actionCommand!=null) this.setActionCommand(actionCommand);
	}
	
	/**
	 * 构造函数 
	 * @param text
	 * @param actionListener
	 */
	public GButton(String text,ActionListener actionListener){
		this(null,null,text);
		this.addActionListener(actionListener);
	}
	
	/** GComponent */
	private GComponent core;
	public GComponent getGCore() {return core;}
	
	
	public void paintChildren(Graphics g) {core.paintChildren(g);super.paintChildren(g);}
	
}
